<template>
    <div>
        <el-dropdown trigger="click" @command="itemChange">
            <span class="el-dropdown-link">
                <span>{{ $store.state.adminname }}</span><i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item :command="1">查看</el-dropdown-item>
                <el-dropdown-item :command="2">新增</el-dropdown-item>
                <el-dropdown-item :command="3">删除</el-dropdown-item>
                <el-dropdown-item :command="4">退出</el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>
</template>

<script>
    import { mapActions } from 'vuex';
    export default {
        name:"HeaderLayout",
        methods:{
            // ...mapActions(["exitAndUpdateAuthorityInfo"]),
            ...mapActions({
                exitLogin:"exitAndUpdateAuthorityInfo",
            }),
            itemChange(commandValue){
                console.log(commandValue);

                if(commandValue == 4){ //退出登录
                    // 1. 清除本地数据  vuex存储数据
                    // 2. 回到登录页
                    this.exitLogin();
                    this.$router.push("/login")
                }

            }
        },
    }
</script>

<style lang="scss" scoped>

</style>